home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** File: TRRectObj.c
- ** Written by: Eric Soldan
- **
- ** Copyright © 1992 Apple Computer, Inc.
- ** All rights reserved.
- */
-
- /* See the files "=How to write your app" and "=Using TreeObj.c" for information
- ** on this function. */
-
- /* This file implements the messages for the round-rect object. Many of the messages
- ** can be handled by the rect object, as they deal with a rect structure. Only
- ** a few of them are round-rect-specific. */
-
- /* It would seem that you would want a custom hit-test message handler here, but
- ** the rect object first checks to see if the hit is within the bounding box of
- ** the object, and if so, it then calls the object to return the region. This
- ** allows the rect object to generically handle hit-testing. */
-
-
-
- /*****************************************************************************/
-
-
-
- #include "App.h" /* Get the application includes/typedefs, etc. */
- #include "App.Common.h" /* Get the stuff in common with rez. */
- #include "App.protos.h" /* Get the prototypes for the application. */
-
- #ifndef __OSEVENTS__
- #include <OSEvents.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __STRING__
- #include <String.h>
- #endif
-
- #ifndef __TREEOBJ2__
- #include "TreeObj2.h"
- #endif
-
- #ifndef __UTILITIES__
- #include "Utilities.h"
- #endif
-
-
-
- #pragma segment DrawObjects
- long TRRectObj(TreeObjHndl hndl, short message, long data)
- {
- Rect rct;
- RgnHandle rgn;
- short w, h;
- #if VH_VERSION
- char *cptr;
- #endif
-
- switch (message) {
- case FREEMESSAGE:
- case COPYMESSAGE:
- case UNDOMESSAGE:
- case CONVERTMESSAGE:
- case FREADMESSAGE:
- case FWRITEMESSAGE:
- case HREADMESSAGE:
- case HWRITEMESSAGE:
- case HITTESTMESSAGE:
- case GETBBOXMESSAGE:
- case SETBBOXMESSAGE:
- case SECTBBOXMESSAGE:
- case TARGETMESSAGE:
- case CLICKMESSAGE:
- case KEYMESSAGE:
- case SETSELECTMESSAGE:
- case GETSELECTMESSAGE:
- case SIZEMESSAGE:
- return(TRectObj(hndl, message, data));
- break;
-
- case INITMESSAGE:
- TRectObj(hndl, message, data);
- mDerefRRect(hndl)->width = mDerefRRect(hndl)->height = 20;
- break;
-
- case GETRGNMESSAGE:
- rgn = NewRgn();
- OpenRgn();
- rct = mDerefRRect(hndl)->rect;
- FrameRoundRect(&rct, mDerefRRect(hndl)->width, mDerefRRect(hndl)->height);
- CloseRgn(rgn);
- return((long)rgn);
- break;
-
- case DRAWMESSAGE:
- rct = mDerefRRect(hndl)->rect;
- w = mDerefRRect(hndl)->width;
- h = mDerefRRect(hndl)->height;
- switch (data) {
- case DRAWOBJ:
- FillRoundRect(&rct, w, h, &qd.white);
- FrameRoundRect(&rct, w, h);
- break;
- case ERASEOBJ:
- EraseRoundRect(&rct, w, h);
- break;
- case DRAWSELECT:
- TRectObj(hndl, message, data);
- break;
- case DRAWGHOST:
- PenMode(patXor);
- FrameRoundRect(&rct, w, h);
- PenNormal();
- break;
- case DRAWMASK:
- FillRoundRect(&rct, w, h, &qd.black);
- break;
- }
- break;
-
- case PRINTMESSAGE:
- TRRectObj(hndl, DRAWMESSAGE, DRAWOBJ);
- break;
-
- #if VH_VERSION
- case VHMESSAGE:
- cptr = ((VHFormatDataPtr)data)->data;
- ccatchr(cptr, 13, 2);
- ccat (cptr, "$10: TRRectObj:");
- ccatchr(cptr, 13, 1);
- ccat (cptr, " $00: selected = ");
- ccatdec(cptr, mDerefRRect(hndl)->selected);
- ccatchr(cptr, 13, 1);
- rct = mDerefRRect(hndl)->rect;
- ccat (cptr, " $02: rect = ($");
- ccathex(cptr, 0, 4, 4, rct.top);
- ccat (cptr, ",$");
- ccathex(cptr, 0, 4, 4, rct.left);
- ccat (cptr, ",$");
- ccathex(cptr, 0, 4, 4, rct.bottom);
- ccat (cptr, ",$");
- ccathex(cptr, 0, 4, 4, rct.right);
- ccat (cptr, ")");
- ccatchr(cptr, 13, 1);
- ccat (cptr, " $0A: width = ");
- ccatdec(cptr, mDerefRRect(hndl)->width);
- ccatchr(cptr, 13, 1);
- ccat (cptr, " $0C: height = ");
- ccatdec(cptr, mDerefRRect(hndl)->height);
- return(true);
- break;
- #endif
-
- default:
- break;
- }
-
- return(noErr);
- }
-
-
-
-